package com.data.center.controller;

import com.data.center.dto.StaffDto;
import com.data.center.exception.ResultBody;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
@Slf4j
class StaffControllerTestSC {
    @Autowired
    StaffController staffController;

    @Test
    void findStaff() {
        StaffDto param = new StaffDto();
        param.setName("测试1");
        param.setEmail("2@");
        param.setMobile("333");
        param.setFax("111");
        param.setTelephone("444");
        log.info("查询" + staffController.findStaff(param));
    }

    @Test
    public void testAddStaff_Error1() {
        // Arrange
        StaffDto staffDto = new StaffDto();
        staffDto.setName("测试2");

        // Act
        ResultBody result = staffController.addStaff(staffDto);

        log.info("失败新增1" + result);

    }

    @Test
    public void testAddStaff_Error2() {
        // Arrange
        StaffDto staffDto = new StaffDto();
        staffDto.setName("测试2");
        staffDto.setTelephone("111");
        // Act
        ResultBody result = staffController.addStaff(staffDto);

        log.info("失败新增2" + result);
    }

    @Test
    public void testAddStaff_Error3() {
        // Arrange
        StaffDto staffDto = new StaffDto();

        // Act
        ResultBody result = staffController.addStaff(staffDto);

        log.info("失败新增3" + result);
    }

    @Test
    public void testAddStaff_Success() {
        // Arrange
        StaffDto staffDto = new StaffDto();
        staffDto.setName("测试2");
        staffDto.setTelephone("222");

        // Act
        ResultBody result = staffController.addStaff(staffDto);

        log.info("成功新增" + result);
    }
}